package Sort;

public class SelectionSort {
    public static void sort(int[] a){
        for (int right =a.length-1;right>=0;right--){
            int max = right;
            for(int i=0;i<right;i++){  //选择找到最大或者最小的数
                if(max<a[i]){
                    max=i;
                }
            }
            if(max!=right){  //max的位置改变了我们再做交换
                int temp = a[max];
                a[max] = a[right];
                a[right] = temp;
            }
        }
    }
}
